package kr.pe.johnkim.dayve.provider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * @author johnkim
 *
 */
public class DayveItemEventDatabaseHelper extends SQLiteOpenHelper {

	private static final String TAG = DayveItemEventDatabaseHelper.class.getSimpleName();
	
	private static final String DATABASE_NAME = "database_dayve_item_event.db";
	private static final int DATABASE_VERSION = 10;
	
	public DayveItemEventDatabaseHelper(Context context) {
		super(context,  DATABASE_NAME, null, DATABASE_VERSION);	
		Log.e(TAG, "DayveItemEventDatabaseHelper");
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		// Item 테이블을 생성 한다.
		db.execSQL(
				" CREATE TABLE if not exists dayve_item_event" + 
						" (" +
						"	  _id				   				 INTEGER PRIMARY KEY AUTOINCREMENT" + 
						"	, id_myhistory_item_events			 TEXT" +
						"   , comment 			   				 TEXT" +
						"   , amount			   				 TEXT" + 
						"   , open_item_event_yn   				 TEXT" +
						"   , favorite_yn		   				 TEXT" + 
						"	, activate_yn		   				 TEXT" +
						"	, modify_date		   				 TEXT" +
						"   , register_date		   				 TEXT" +
						"   , myhistory_members_id	             TEXT" + 
						"   , myhistory_items_id_myhistory_items TEXT" + 
						");"
				);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		// Item 테이블을 삭제 한다.
		db.execSQL("DROP TABLE if exists dayve_item_event");

		// 테이블을 새로 생성 한다.
		onCreate(db);
	}
}
